package com.yoomiito.app.present.account;

import com.yoomiito.app.base.AppConfig;
import com.yoomiito.app.base.BaseAccountPresent;
import com.yoomiito.app.model.bean.GuiMIHuiBean;
import com.yoomiito.app.net.YmApi;
import com.yoomiito.app.ui.account.GuiMIHuiLoginActivity;
import com.yoomiito.app.utils.NetworkUtils;

import cn.droidlover.xdroidmvp.net.ApiException;
import cn.droidlover.xdroidmvp.net.ApiSubscriber;
import cn.droidlover.xdroidmvp.net.XApi;

public class GuiMiHuiLoginPresent extends BaseAccountPresent<GuiMIHuiLoginActivity> {

    public GuiMiHuiLoginPresent(AppConfig appConfig) {
        super(appConfig);
    }

    public void sureId(String id){
        if (NetworkUtils.checkNetPermission(getV())){
            return;
        }
        YmApi.getYmService()
                .sureGuiMiHuiId(id)
                .compose(getV().bindToLifecycle())
                .compose(XApi.getApiTransformerData())
                .compose(XApi.getScheduler())
                .subscribe(new ApiSubscriber<GuiMIHuiBean>(handleException()) {
                    @Override
                    public void onSuccess(GuiMIHuiBean bean) {
                        getV().showId(bean);
                    }

                    @Override
                    public void onFail(ApiException error) {

                    }
                });
    }

}
